package 剑指offer.zw_14I_剪绳子;

class Solution {
    public int cuttingRope(int n) {
        if (n < 4) return n - 1;
        int quotient = n / 3;
        int remainder = n % 3;
        if (remainder == 0) {
            return (int) Math.pow(3, quotient);
        } else if (remainder == 1) {
            return (int) Math.pow(3, quotient - 1) * 4;
        } else {
            return (int) Math.pow(3, quotient) * 2;
        }
    }
}
